﻿using System.Data;
using MyFloridaHouse.libSvDTO;

namespace MyFloridaHouse.DataAccess.Extensions
{
	/// <summary>
	/// [Obsolete] LayerFieldDataDTODataContract
	/// </summary>
    public static class LayerFieldDataDTODataContract
    {
		//Todo: Remove unused code.
		/// <summary>
		/// [Obsolete] DataContract
		/// </summary>
		/// <param name="rdr">The RDR.</param>
		/// <returns></returns>
        public static LayerFieldDataDTO DataContract(IDataReader rdr)
        {
            // this is the correct way to ensure no null's crash the application
            // use the "null-coalescing" operator "??" to test for null and substitute a default value
            //newItem.layerid = rdr["layerid"] is DBNull ? 0 : Convert.ToInt32(rdr["layerid"]);
            // but assume there are no nulls for speed
            var newItem = new LayerFieldDataDTO
                          	{
                          		layerID = (int) rdr["layerid"],
                          		dictionaryID = (int) rdr["dictionaryid"],
                          		fieldName = rdr["fieldName"].ToString()
                          	};


			return newItem;
        }
    }
}
